bitkeeper revision 1.1159.1.118 (41370c33N7_5pjKepga6V4ZmyTSNnQ)
authormjw@wray-m-3.hpl.hp.com <mjw@wray-m-3.hpl.hp.com>
Thu, 2 Sep 2004 12:04:03 +0000 (12:04 +0000)
committermjw@wray-m-3.hpl.hp.com <mjw@wray-m-3.hpl.hp.com>
Thu, 2 Sep 2004 12:04:03 +0000 (12:04 +0000)
Add support for maxmem in xm create and config.

docs/xen_config.html
tools/python/xen/xend/XendDomainInfo.py
tools/python/xen/xm/create.py

index 95493f75560039de339ce44ac9f34112f0a48549..447ebeec53403536843038626e5d5f14034443e7 100644 (file)
@@ -60,6 +60,7 @@ The top-level element, a virtual machine configuration.
     <li>name: string, required. Domain name.
     <li>id: int, optional, default generated. Domain unique id.
     <li>memory: int, required. Domain memory in MB.
+    <li>maxmem: int, optional. Maximum domain memory in MB.
     <li>cpu: int, optional. Cpu to run on.
     <li>cpu_weight, float, optional, default 1. Cpu weight - controls share of CPU.
     <li>image: linux | netbsd | ..., required. Domain image (OS-specific element).
index 88a9d5b5c3146e16b7938b2bebf5e896a84f8c11..b86167143baf0ed79b38b478a6b03b74a9c093d6 100644 (file)
@@ -831,6 +831,14 @@ class XendDomainInfo:
             self.config.remove(['device', dev_config])
         dev.destroy()
 
+    def configure_memory(self):
+        """Configure vm memory limit.
+        """
+        maxmem = sxp.get_child_value(self.config, "maxmem")
+        if maxmem is None:
+            maxmem = self.memory
+        xc.domain_setmaxmem(self.dom, maxmem_kb = maxmem * 1024)
+
     def configure_console(self):
         """Configure the vm console port.
         """
@@ -1140,11 +1148,28 @@ def vm_field_ignore(vm, config, val, index):
 
     @param vm:        virtual machine
     @param config:    vm config
-    @param val:       vfr field
+    @param val:       config field
     @param index:     field index
     """
     pass
 
+def vm_field_maxmem(vm, config, val, index):
+    """Configure vm memory limit.
+
+    @param vm:        virtual machine
+    @param config:    vm config
+    @param val:       config field
+    @param index:     field index
+    """
+    maxmem = sxp.child0(val)
+    if maxmem is None:
+        maxmem = vm.memory
+    try:
+        maxmem = int(maxmem)
+    except:
+        raise VmError("invalid maxmem: " + str(maxmem))
+    xc.domain_setmaxmem(vm.dom, maxmem_kb = maxmem * 1024)
+
 # Register image handlers.
 add_image_handler('linux',  vm_image_linux)
 add_image_handler('netbsd', vm_image_netbsd)
@@ -1165,3 +1190,4 @@ add_config_handler('device',     vm_field_ignore)
 add_config_handler('backend',    vm_field_ignore)
 
 # Register other config handlers.
+add_config_handler('maxmem',     vm_field_maxmem)
index 01ab1e8a12fe6bfc82d7689901c85e6bce8917c8..5dfa698f9d61f0c373a59a9c314fcd93fe5a988a 100644 (file)
@@ -99,6 +99,10 @@ gopts.var('memory', val='MEMORY',
           fn=set_int, default=128,
           use="Domain memory in MB.")
 
+gopts.var('maxmem', val='MEMORY',
+          fn=set_int, default=None,
+          use="Maximum domain memory in MB.")
+
 gopts.var('cpu', val='CPU',
           fn=set_int, default=None,
           use="CPU to run the domain on.")
@@ -310,6 +314,8 @@ def make_config(vals):
     config = ['vm',
               ['name', vals.name ],
               ['memory', vals.memory ]]
+    if vals.maxmem:
+        config.append(['maxmem', vals.maxmem])
     if vals.cpu is not None:
         config.append(['cpu', vals.cpu])
     if vals.cpu_weight is not None: